"""
内容:点击用户中心,点击用户信息修改
作者:刘芳
"""
#引入模块
from common.base import Base,create_browser_op,base_sql_add
import time

#创建类
class PageUserMessage(Base):
    #定义属性
    url="http://localhost:8080/ecshop/index.php"
    user=("xpath","//a[@href='user.php']")
    message=("xpath","//a[@href='user.php?act=profile']")
    year=("name","birthdayYear")
    month=("name","birthdayMonth")
    day=("name","birthdayDay")
    sure=("name","submit")
    text=("xpath","//div[@class='boxCenterList']/div/p")
    #定义方法
    #打开网页
    def page_user_message_open_web(self):
        self.base_open_web(self.url)
    #点击用户中心
    def page_user_message_click(self):
        self.base_click(self.user)
    #点击用户信息
    def page_user_message_click_user(self):
        self.base_click(self.message)
    #点击生日年份
    def page_user_message_click_year(self,your_year):
        self.base_select(self.year,your_year)
    #点击生日月份
    def page_user_message_click_month(self,your_month):
        self.base_select(self.month,your_month)
    #点击生日日期
    def page_user_message_click_day(self,your_day):
        self.base_select(self.day,your_day)
    #点击确认修改
    def page_user_message_click_sure(self):
        self.base_click(self.sure)
    #退出
    def page_user_message_quit(self):
        self.base_quit()
    #获取文本
    def page_user_message_get_text(self):
        return self.base_get_text(self.text)

if __name__ == '__main__':
    p=PageUserMessage(create_browser_op(r'C:\Users\86184\AppData\Local\Google\Chrome\User Data'))
    p.page_user_message_open_web()
    p.page_user_message_click()
    p.page_user_message_click_user()
    p.page_user_message_click_year('1995')
    p.page_user_message_click_month('12')
    p.page_user_message_click_day('16')
    p.page_user_message_click_sure()
    time.sleep(6)
    print(base_sql_add("SELECT birthday FROM `ecs_users` where user_name='liu999'", "birthday"))
    # p.page_user_message_quit()